﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeRepositoryConsole.OOP
{
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // : base (parameters)
    // : this (parameters)
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


    public class CtorBase
    {
        public CtorBase() { }
        public CtorBase(int id)
        {
            Console.WriteLine("Ctor Base");
        }
    }


    /// <summary>
    /// <seealso cref="http://stackoverflow.com/questions/4009013/call-one-constructor-from-another"/>
    /// </summary>
    public class CtorChild : CtorBase
    {
        public CtorChild(int id) : this(id, "")
        {
            // call CtorChild(int id, string name)
            Console.WriteLine("Ctor First.");
        }

        public CtorChild(int id, string name) : base(id)
        {
            // Instance variable storage is set to 0
            // instance variable initializer execute
            // bace class instance constructor executes
            Console.WriteLine("Ctor Second");
        }
    }
}
